home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
vp2_409e.szh
/
HW.C
< prev
next >
Wrap
Text File
|
1991-06-27
|
6KB
|
213 lines
/*
$Header: hw.c 3.3 87/12/12 00:42:46 Bob Exp $
The Conference Mail System
This module was originally written by Bob Hartman
Sysop of FidoNet node 1:132/101
Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
The Conference Mail System is a complete Echomail processing package. It
is a superset of the original Echomail utilities created by Jeff Rush, and
also contains ideas gleaned from the ARCmail, Renum, oMMM, MGM, and Opus
programs that were created by various software authors.
This program source code is being released with the following provisions:
1. You are free to make changes to this source code for use on your own
machine, however, altered source files may not be distributed without the
consent of Spark Software.
2. You may distribute "patches" or "diff" files for any changes that you
have made, provided that the "patch" or "diff" files are also sent to Spark
Software for inclusion in future releases of the entire package. A "diff"
file for the source archives may also contain a compiled version, provided
it is clearly marked as not being created from the original source code.
No other executable versions may be distributed without the consent of
Spark Software.
3. You are free to include portions of this source code in any program you
develop, providing: a) Credit is given to Spark Software for any code that
may is used, and b) The resulting program is free to anyone wanting to use
it, including commercial and government users.
4. There is NO technical support available for dealing with this source
code, or the accompanying executable files. This source code is provided
as is, with no warranty expressed or implied (I hate legalease). In other
words, if you don't know what to do with it, don't use it, and if you are
brave enough to use it, you're on your own.
Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
on the public FidoNet network, or at the address given above.
To use this code you will need Microsoft C version 4.0, and also Microsoft
Macro Assembler version 4.0.
*/
/*
$Log: hw.c $
* Revision 3.3 87/12/12 00:42:46 Bob
* Source code release
*
*/
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <io.h>
#include <string.h>
#include <time.h>
#include <sys\types.h>
#include <sys\stat.h>
#include "fastecho.h"
#define DEBUG 0
extern int high_one;
extern char tearline[];
extern int ctrla;
extern int hwptr;
extern struct tm *t2;
extern struct _stamp cur_stamp;
extern struct _stamp zero_stamp;
extern char *_months[];
extern char *weekday[];
void get_hw (AREAS_PTR which)
{
int f;
char fname1[80];
MSG m;
int *hptr;
/* Open message 1 */
/* Create the message file name */
sprintf (fname1, "%s\\1.MSG", which->msg_path);
if (hwptr)
hptr = &(m.up);
else
hptr = &(m.reply);
/* Set up a default */
*hptr = 1;
#if DEBUG
printf ("getting high water from '%s'\n", fname1);
#endif
/* Open up new message file */
if((f = open (fname1, O_RDONLY|O_BINARY)) == -1)
{
#if DEBUG
printf ("high water mark does not exist\n");
#endif
/* It does not exist, so just return first message */
/* By returning 0 find_msg() will give the first real message */
high_one = 0;
return;
}
(void) fast_read (f, (char *) &m, sizeof (MSG));
#if DEBUG
printf ("reply = %d, up = %d, from = '%s'\n", m.reply, m.up, m.from);
#endif
(void) fast_close (f);
high_one = *hptr;
#if DEBUG
printf ("returning %d as the high water mark\n", high_one);
#endif
}
void set_hw (int mnum,AREAS_PTR which)
{
int f, foo;
char fname1[80];
char mess[100];
MSG m;
int *hptr;
/* Open message 1 */
/* Create the message file name */
sprintf (fname1, "%s\\1.MSG", which->msg_path);
#if DEBUG
printf ("getting high water from '%s'\n", fname1);
#endif
if (hwptr)
hptr = &(m.up);
else
hptr = &(m.reply);
memset ((char *) &m, 0, sizeof (MSG));
foo = 0;
/* Open up new message file */
if((f = open (fname1, O_RDONLY|O_BINARY)) == -1)
{
foo = 1;
/* It does not exist, so create it */
if ((f = open (fname1, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE)) == -1)
{
/* Could not even create it */
printf ("\nCould not store High Water Mark for area '%s'", which->area_name);
return;
}
strcpy (m.from, &tearline[6]);
m.from[strlen(m.from)-1] = '\0';
m.from[strlen(m.from)-1] = '\0';
strcpy (m.to, m.from);
strcpy (m.subj, "ConfMail High Water Mark Stored Here");
m.times = 0;
m.dest = -1;
m.orig = -1;
m.cost = 0;
m.orig_net = -1;
m.dest_net = -1;
m.attr = MSGSENT|MSGPRIVATE;
m.up = 0;
m.reply = 0;
#if DEBUG
printf ("High water message being created\n");
#endif
}
else
{
#if DEBUG
printf ("Found high water message\n");
#endif
(void) fast_read (f, (char *) &m, sizeof (MSG));
(void) fast_close (f);
f = open (fname1, O_RDWR|O_BINARY);
}
/* Save the high water mark */
*hptr = mnum;
/* Alway stick in the date arrived */
m._date_arrived = zero_stamp;
/* Stick in a valid date */
sprintf (m.date, "%3.3s %2d %3.3s %02d %02d:%02d",
weekday[t2->tm_wday], t2->tm_mday, _months[t2->tm_mon],
t2->tm_year, t2->tm_hour, t2->tm_min);
m.date[8] = (char) tolower (m.date[8]);
m.date[9] = (char) tolower (m.date[9]);
m._date_written = m._date_arrived = zero_stamp;
(void) fast_write (f, (char *) &m, sizeof (MSG));
if (foo)
{
sprintf (mess, "NOECHO\r\n\r\nIgnore this message!\r\rIt is only used by the Conference Mail System.\r\r");
(void) fast_write (f, mess, strlen(mess));
}
(void) fast_close (f);
}